package com.cn.por.biz.bigtable.dto;
import com.cn.por.biz.bigtable.entity.BigTableDO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
/**
 * <p>Converter</p>
 * @author xw
 * @since 2025-06-02
 */
@Component
public class BigTableDTOConverter{

    /**
     * DTO-->DO
     */
    public BigTableDO convertToBigTableDO(BigTableDTO bigTableDTO){
      BigTableDO bigTableDO = new BigTableDO();
      BeanUtils.copyProperties(bigTableDTO,bigTableDO);
      if(StrUtil.isNotEmpty(bigTableDTO.getBirthday())){
            bigTableDO.setBirthday(DateUtil.parse(bigTableDTO.getBirthday(), DatePattern.NORM_DATETIME_PATTERN));
        }
      if(StrUtil.isNotEmpty(bigTableDTO.getUpdatedTime())){
            bigTableDO.setUpdatedTime(DateUtil.parse(bigTableDTO.getUpdatedTime(), DatePattern.NORM_DATETIME_PATTERN));
        }
      return bigTableDO;
    }
    

    /**
     * DO-->DTO
     */
    public BigTableDTO convertToBigTableDTO(BigTableDO bigTableDO){
      BigTableDTO bigTableDTO = new BigTableDTO();
      BeanUtils.copyProperties(bigTableDO,bigTableDTO);
      if(null!=bigTableDO.getBirthday()){
            bigTableDTO.setBirthday(DateUtil.format(bigTableDO.getBirthday(), DatePattern.NORM_DATETIME_PATTERN));
        }
      if(null!=bigTableDO.getUpdatedTime()){
            bigTableDTO.setUpdatedTime(DateUtil.format(bigTableDO.getUpdatedTime(), DatePattern.NORM_DATETIME_PATTERN));
        }
      return bigTableDTO;
    }
    

}